package com.stone.serverless.test2.service;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import com.stone.serverless.orm.BaseMapper;
import com.stone.serverless.test2.ExposeServiceManager;
import com.stone.serverless.test2.NeedOutServiceManager;
import com.stone.serverless.test2.controller.Test2OutService;
import com.stone.serverless.test2.domain.Test2VO;
import com.stone.serverless.test2.entity.EmrWriteRecordOutpatientDO;
import com.stone.serverless.test2.mapper.OutPatientMapper;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.List;

/**
 * @Description: TODO
 * @Author: MECHREVO
 * @Date: 2022/1/14 13:30
 * @Version: 1.0.0
 */
@Service
public class Test2Service extends Test2OutService implements InitializingBean {


    @Override
    public void afterPropertiesSet() throws Exception {
        ExposeServiceManager.INSTANCE.add(this);
    }

    @Override
    public String test2() {
        OutPatientMapper register = NeedOutServiceManager.INSTANCE.mapperRegisterService.register(OutPatientMapper.class);

        List<EmrWriteRecordOutpatientDO> query1 = register.query();



        NeedOutServiceManager exposeServiceManager = NeedOutServiceManager.INSTANCE;
        DataSource ds = exposeServiceManager.dataSourceService.dataSource();
        Db use = Db.use(ds);
        try {
            List<Entity> query = use.query("select id from emr_write_record_outpatient_0 limit 10");
            System.out.println("x");
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;
    }

    @Override
    public Test2VO test3(Test2VO test2VO) {
        Test2VO test2VO1 = new Test2VO();
        test2VO1.setId("sfdsafsdfsdfsdfsdf");
        return test2VO1;
    }


}
